package com.demo.ctrl;

import com.demo.aspect.annotation.LogAnnotation;
import com.demo.event.TestEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhangxiangnan
 * @date 2021/8/18  23:02
 */
@RestController
@RequestMapping("/process")
public class TestController {
    @Autowired
    private ApplicationContext applicationContext;

    @GetMapping("/getdemo")
    public String getDemo(){
        System.out.println(">>>> get demo ");
        return "you have success";
    }

    @GetMapping("/listener")
    public String listener(){
        System.out.println(">>>> listener");
        applicationContext.publishEvent(new TestEvent(applicationContext));
        return " you listener request success";
    }

    @GetMapping("/aspect")
    @LogAnnotation(name = "zxn",value = "122")
    public String aspect(){
        System.out.println(">>>> aspect");
        return " you aspect request success";
    }
}
